#pragma once

#include <iostream>

class BitMap
{
public:
	BitMap()
	{
		data = new unsigned int[group_count];
		for (unsigned int i = 0; i < group_count; i++)
		{
			data[i] = 0;
		}
	}
	explicit BitMap(std::istream& in) : BitMap()
	{
		unsigned int number;
		while (in >> number)
		{
			Add(number);
		}
	}
	BitMap(const BitMap& other) = delete;
	BitMap& operator=(const BitMap& other) = delete;
	~BitMap()
	{
		delete[] data;
	}
	void Add(const unsigned int n)
	{
		const unsigned int group_index = n / group_size;
		const unsigned int offset = n % group_size;
		
		data[group_index] |= one << offset;
	}
	void Remove(const unsigned int n)
	{
		const unsigned int group_index = n / group_size;
		const unsigned int offset = n % group_size;
		
		data[group_index] &= ~(one << offset);
	}
	bool Contains(const unsigned int n) const
	{
		const unsigned int group_index = n / group_size;
		const unsigned int offset = n % group_size;
		
		return (data[group_index] & one << offset) != 0;
	}
private:
	static constexpr unsigned int max_count = 150000;
	static constexpr unsigned int group_size = 32;
	static constexpr unsigned int group_count = max_count / group_size;
	static constexpr unsigned int one = 1;
	unsigned int* data;
};

void test_bitmap();